package com.asion.controller;

import com.asion.domain.Detail;
import com.asion.domain.Video;
import com.asion.domain.Visitor;
import com.asion.mapper.DetailMapper;
import com.asion.mapper.VideoMapper;
import com.asion.mapper.VisitorMapper;
import com.asion.vo.VideoVo;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.mysql.cj.util.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.text.SimpleDateFormat;
import java.util.Date;

@RestController
@RequestMapping("/app")
public class AppController {
    @Autowired
    private VisitorMapper visitorMapper;
    @RequestMapping("/version")
    private String version(){
        try {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            String dateString = sdf.format(new Date().getTime());
            InetAddress localHost = InetAddress.getLocalHost();
            String ipAddress = localHost.getHostAddress();
            System.out.println("本机IP地址：" + ipAddress);
            Visitor visitor = new Visitor();
            visitor.setIp(ipAddress);
            visitor.setPlatform("mobile");
            visitor.setCreate_time(dateString);
            visitorMapper.insert(visitor);
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
      return "1.0.0";
    }

}
